** Enhances Thor's signature systems implementing both a random tag
** and a specific conference's signature. Default signature allowed.
**
** $HISTORY:
**
** 21 Oct 1999 : 000.002 : Added pattern support for Conference name
** 20 Oct 1999 : 000.001 : First attempt, based from mine GMAutoWrite (try it! ;-)
**
*/
;parse upper arg "BBSNAME" BBS "CONFNAME" CNAME .;BBS=strip(compress(BBS,'"'));CNAME=strip(compress(CNAME,'"'));if BBS=""|CNAME="" then;call ExitMsg("GMSignature.thor must be called as Thor's Signature Command");ConfigFile='ENV:Thor/'||BBS||'.cfg';if ~Exists(ConfigFile) then;exit;VerStr=subword(sourceline(2),3);true=1;false=0;TagOptsBlk="TagPgm";TagOptsZro="TagPgmType";TagOptions="SigFile" TagOptsBlk TagOptsZro;NumOpts=words(TagOptions);call ReadConfig;call Validate;index=SrcConf(CNAME);if index=0 then;index=SrcConf("DEFAULT");if Exists(Tags.index.SIGFILE) then;address command 'type' Tags.index.SIGFILE;else;call ExitMsg("'SigFile' '"||Tags.index.SIGFILE||"' not found!");if Tags.index.TAGPGM ~='' then;do;say "--";if Tags.index.TAGPGMTYPE=0 then;Tags.index.TAGPGM;else;address command Tags.index.TAGPGM;end;exit;Validate:;DefFound=false;do i=1 to Tags.0;if upper(Tags.i)="DEFAULT" then;DefFound=true;do y=1 to NumOpts;Opt=upper(word(TagOptions,y));OptDef=symbol('Tags.i.Opt');Select;When find(upper(TagOptsBlk),Opt)>0 then;if OptDef ~='VAR' then Tags.i.Opt='';When find(upper(TagOptsZro),Opt)>0 then;if OptDef ~='VAR' then Tags.i.Opt=0;Otherwise;if OptDef ~='VAR' then call ExitMsg("'"||Opt||"' not defined in tag '"||Tags.i||"'");end;end;end;if ~DefFound then;call ExitMsg("'DEFAULT' tag not defined in file '"||ConfigFile||"'");return;SrcConf:;cnfr=arg(1);do i=1 to Tags.0;CONF=cnfr;if Tags.i.PAT=0 then;do;if CONF=Tags.i then return i;end;else;do;select;when Tags.i.PAT=1 then;do;CONF=left(CONF,length(Tags.i));if CONF=Tags.i then return i;end;when Tags.i.PAT=2 then;do;CONF=right(CONF,length(Tags.i));if CONF=Tags.i then return i;end;when Tags.i.PAT=3 then;do;if index(CONF,Tags.i)>0 then return i;end;end;end;end;return 0;ReadConfig:;drop Tags.;Tags.0=0;TagsNum=0;CfgOpen=open(cfgfile,ConfigFile,'r');if ~(CfgOpen) then call ExitMsg('Reading: failed to open' ConfigFile);do until eof(cfgfile);nextline=readln(cfgfile);if compress(nextline)="" then iterate;parse var nextline CfgName CfgVal;CfgName=upper(CfgName);CfgVal=strip(compress(CfgVal,'"'));if CfgName='TAG' then;do;TagsNum=TagsNum+1;pattern=0;if right(CfgVal,1)='*' then;pattern=pattern+1;if left(CfgVal,1)='*' then;pattern=pattern+2;CfgVal=compress(CfgVal,'*');Tags.TagsNum.PAT=pattern;Tags.TagsNum=upper(CfgVal);end;else;do;if TagsNum=0 then call ExitMsg('No Tag names found!');if find(upper(TagOptions),CfgName)>0 then;Tags.TagsNum.CfgName=CfgVal;else;call ExitMsg("Option '"||CfgName||"' (with value '"||CfgVal||"') in tag '"||Tags.TagsNum||"' not allowed!");end;end;if TagsNum=0 then call ExitMsg('No Tag names found!');Tags.0=TagsNum;if (CfgOpen) then dummy=close(cfgfile);return;ExitMsg:;parse arg msgstr;address command;'RequestChoice >NIL: "GMSignature.thor" "'msgstr'" "OK :-("';exit